const gulp = require("gulp")
const sass = require("gulp-sass")(require('sass'))
const pug = require("gulp-pug")
const browserSync = require("browser-sync").create()

const path = require('path');
const folderPath = path.dirname(__filename);



gulp.task('compileSass', async () => {
  gulp.src(`scss/*.scss`)
    // 编译sass
    .pipe(sass())
    // 输出编译后的css文件
    .pipe(gulp.dest(`dist/css`))
    // sass编译完成后刷新
    .pipe(browserSync.stream());
})

gulp.task("compilePug", async () => {
  gulp.src(`pug/*.pug`)
    // 编译sass
    .pipe(pug({pretty: true}))
    // 输出编译后的css文件
    .pipe(gulp.dest(`dist`))
    .pipe(browserSync.stream());
})

gulp.task('serve', async () => {
  browserSync.init({
    server: './dist',
    port: 3306
  });
  gulp.watch("./scss", gulp.series("compileSass"));
  gulp.watch("./pug", gulp.series("compilePug"));
})




// gulp.task('default', ['serve']);